// KFrameBuffer.cpp: implementation of the KFrameBuffer class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "KFrameBuffer.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

KFrameBuffer::KFrameBuffer(size_t cxWidth, size_t cxHeight) 
{
	m_pfZBuffer = 0;
	Create(cxWidth, cxHeight);
}

KFrameBuffer::~KFrameBuffer()
{
	if(m_pfZBuffer) delete m_pfZBuffer;
}

bool KFrameBuffer::Create(size_t cxWidth, size_t cxHeight) 
{ 
	if(!m_kSurface.Create(cxWidth, cxHeight))
		return false;

	if(m_pfZBuffer) delete m_pfZBuffer;
	m_pfZBuffer = new float[cxWidth*cxHeight];
	ZeroMemory(m_pfZBuffer, cxWidth*cxHeight*sizeof(float));

	return true;
}